#!/usr/bin/perl -w
# vim:tw=100 sw=2 expandtab ft=perl
# Example:
#
# dir_install => {
#   '/tmp/test' => {
#     source => 'rollout:/files/test',
#     dir_mode => 0755,
#     mode => 0644,
#     owner => 'root',
#     group => 'daemon',
#     command => "find /tmp/test -ls",
#   },
# },

my %dir_install = flatten_hash(c("$hostname/dir_install"));
while (my($dest, $src) = each(%dir_install)) {
  next unless i_should($dest);
  $src = { -src => $src } if ref $src ne 'HASH';
  $src = { map { (/^-/ ? $_ : "-$_") => $src->{$_} } keys %$src };
  $src->{-dest} |= $dest;
  $src->{-src} ||= $src->{-source} if $src->{-source};
  $src->{-cmd} ||= $src->{-command} if $src->{-command};
  dir_install(%$src);
}
